﻿Param(
 [String]$port = '51213'
)
$hostname = $env:COMPUTERNAME
$cer = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.FriendlyName -eq 'SSL Certificate for '+$hostname }
if (!$cer) { 
    $cer = New-SelfSignedCertificate -CertStoreLocation cert:\LocalMachine\My -DnsName $hostname 
    $cer.FriendlyName = 'SSL Certificate for '+$hostname
}
$nul = netsh http delete sslcert ipport=0.0.0.0:$port
netsh http add sslcert ipport=0.0.0.0:$port certhash=($cer.Thumbprint) appid='{00000000-0000-0000-0000-000000000000}'
$nul = netsh http delete urlacl url=https://+:$port/
netsh http add urlacl url=https://+:$port/ user=BUILTIN\users
